#include <iostream>
using std::cout;
using std::endl;

class Point
{
public:
    Point(int x ,int y)
    : _ix(x)
    , _iy(y)
    {
        cout << "Point(int,int)" << endl;
    }

    //参数中的&如果去掉，进行复制操作时
    //会陷入拷贝构造的递归调用
    //const如果去掉，一是不能保证在拷贝构造中一定不会修改右操作数内容
    //二是不能接受右值属性对象的内容来进行复制
    Point(const Point & rhs)
    : _ix(rhs._ix)
    , _iy(rhs._iy)
    {
        /* rhs._ix = 100000; */
        cout << "Point(const Point &)" << endl;
    }
    

    void print(){
        cout << "(" << _ix
            << "," << _iy
            << ")" << endl;
    }

    ~Point(){
        cout << "~Point()" << endl;
    }
private:
    int _ix;
    int _iy;
};

void test0(){
    Point p1(1,8);
    /* Point p2(p1); */
    Point p2 = p1;
    p2.print();
    p1.print();
}

void test1(){
    Point pt = Point(8,9);
    pt.print();

}

int main(void){
    test1();
    return 0;
}
